package chapter10.practice8;

/**
 * 测试外部类能否访问内部类的private 元素
 * Created by yangliwei on 2017/10/20.
 */
public class Outer {

    class Inner{
        private String item = "yep you can access field";
        private String getItem(){
            item+=" and you can access funciton";
            return item;
        }
    }

    public void printInner(){
        Inner inner = new Inner();
        //可以直接访问内部类的私有元素
        System.out.println(inner.item);
        System.out.println(inner.getItem());
    }

    public static void main(String[] args) {
        Outer outer  = new Outer();
        outer.printInner();
    }
}
